<template>
    <div class='connector-app code-node' @click="open">
      <div class="header">
        执行代码
      </div>
      <div class="app-info-empty" v-if="app.data.title">
        <span class="code-title"> {{ app.data.title }}</span>
        <i class="iconfont icon-right1" />
      </div>
      <div class="app-info-empty" v-else>
        执行代码的名称
        <i class="iconfont icon-right1" />
      </div>
    </div>
  </template>
  <script>
  
  export default {
    name:'executionCode',
    props:{
      nodeConfig:{
        type:Object,
        default:()=>({})
      },
      moduleList:{
        type:Array,
        default:()=>([])
      },
      parent:{
        type:Object,
        default:()=>({})
      }
    },
    watch:{
      nodeConfig:{
        handler(newVal){
          this.app = newVal
        },
        deep:true,
        immediate:true
      },
      parentApp:{
        // 切换发起应用时候 将消息配置清空
        handler(newVal) {
          if(this.app.isEdit){
            this.app.isEdit = false
          }
          this.$emit('update:nodeConfig', this.app)
        },
        deep: true,
        immediate: true
      }
    },
    computed:{
      parentApp() {
        return this.parent.getParent().isTrigger
          ? this.parent.getParent().getParent().data
          : this.parent.getParent().data;
      },
    },
    data(){
      return {
        app:this.nodeConfig,
        treeDefaultProps:{
          children: 'children',
          label: 'name',
          key: 'bizTypeId',
        }
      }
    },
    methods:{
      handleTreeSelect(val){
        let data = {
          bizActionName:'',
          bizActionCode:'',
        }
        if(val){
          let {bizActionName, bizActionCode} = val
          data = {bizActionName, bizActionCode}
        }
        this.app.data = data
        this.$emit('update:nodeConfig', this.app)
      },
      open(){
        this.$emit('open')
      }
    },
  }
  
  </script>